﻿@model PagedList.IPagedList<SGIMail.Models.ContactViewModel>
@using PagedList.Mvc;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />
@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>
@using (Html.BeginForm("Index", "Contacts", FormMethod.Get))
{
    <p>
        Find by Name/Company: @Html.TextBox("searchString", ViewBag.CurrentFilter as string)
        <input type="submit" value="Search" />
    </p>
}

<table class="table">
    <tr>
        <th>
            Name
        </th>
        <th>
            Email
        </th>
        <th>
            Phone
        </th>

        <th>
            @Html.ActionLink("Company", "Index", new { sortOrder = ViewBag.CompanyNameSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            @Html.ActionLink("Last Active Date", "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            Registrations/ Invitations
        </th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @Html.DisplayFor(modelItem => item.Contact.Name)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contact.Email)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contact.Phone)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Contact.Company.CompanyName)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.LastDateActive)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Participation)
            </td>
            <td>
                @Html.ActionLink("Edit", "Edit", new { id = item.Contact.ContactId }) |
                @Html.ActionLink("Details", "Details", new { id = item.Contact.ContactId }) |
                @Html.ActionLink("Delete", "Delete", new { id = item.Contact.ContactId })
            </td>
        </tr>
    }
</table>
<br />

Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))
